//
//  HXTFuLiViewModel.m
//  HonlivApp
//
//  Created by admin on 2017/6/27.
//  Copyright © 2017年 honliv. All rights reserved.
//

#import "HXTFuLiViewModel.h"
#import "HXTFLInfoModel.h"

static NSString *const HXTFL_url = @"api/Hxt/HxtInfodzqBalance?HxtCardNo=";

@implementation HXTFuLiViewModel

-(void)getHXTFLInfo:(void (^)())completion{
    User *user = [User currentUser];
    NSString *url = [NSString stringWithFormat:@"%@%@%@",HOSPITAL_URL,HXTFL_url,user.MedicalCard];
    [NetWorker getHXTDatasWithURLStr:url success:^(id result) {
        NSDictionary *resultDic = result[@"result"];
        NSArray *dataList = [JsonHelper arrayWithJsonString:resultDic[@"dataList"]];
        NSMutableArray *modelArr = [NSMutableArray array];
        if (dataList.count > 0) {
            for (NSDictionary *dic in dataList) {
                HXTFLInfoModel *model = [HXTFLInfoModel yy_modelWithDictionary:dic];
                [modelArr addObject:model];
            }
            _datasArray = [NSArray arrayWithArray:modelArr];
            completion(modelArr);
        }else{
            completion([NSArray array]);
        }
    } failure:^(id result) {
        _datasArray = [NSArray array];
        completion([NSArray array]);
    }];

}

@end
